package dryven.util.json.dryvenjson.encoders;

import java.io.IOException;

import dryven.model.di.LocalThreadStorage;
import dryven.util.json.JsonEncoder;
import dryven.util.json.dryvenjson.FieldPolicy;
import dryven.util.json.dryvenjson.JSONCompositeEncoder;
import dryven.util.json.dryvenjson.JSONTypeEncoder;

public class EnumEncoder implements JSONTypeEncoder {

	@Override
	public boolean isApplicableForType(Class<?> type) {
		return type.isEnum();
	}

	@Override
	public void encodeValue(Object value, JSONCompositeEncoder e, FieldPolicy p, LocalThreadStorage diStorage, Appendable dest) throws IOException {
		e.encodePropertyValue(value.toString(),diStorage,dest);
	}

}
